package com.heima.article.listen;


import com.heima.article.service.MessageHandler;
import com.heima.common.constants.HotArticleConstants;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class ArticleIncrHandleListener {

    @Autowired
    private MessageHandler messageHandler;
    @KafkaListener(topics = HotArticleConstants.HOT_ARTICLE_INCR_HANDLE_TOPIC)
    public void onMessage(String message) {
        log.info("消费者接收mess: {}", message);

        if (StringUtils.isNotBlank( message)){
            messageHandler.RealTimeArtHotMessageHandler(message);
        }
        // 更新数据库

        // 实时处理分值

        // 更新缓存
            //获取缓存数据
            //判断是否存在
            //判断数量
            //更新缓存数据
    }
}
